package com.example.abe.diandi.category.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.BindView;
import com.example.OnClick;
import com.example.abe.diandi.R;
import com.example.abe.diandi.base.BaseActivity;
import com.example.abe.diandi.category.adapter.CategoryDelegate;
import com.example.abe.diandi.category.model.CategoryModel;
import com.example.abe.diandi.main.AppConfig;

import java.util.ArrayList;
import java.util.List;

import example.abe.com.framework.recycleview.adapter.BaseAdapter;

public class CategoryActivity extends BaseActivity {

    @BindView(R.id.act_category_rv)
    protected RecyclerView mRv;

    private BaseAdapter<CategoryModel> mAdapter;

    private List<CategoryModel> mListData;

    @Override
    public int getLayoutID() {
        return R.layout.activity_category;
    }

    @Override
    public void initData() {
        mListData = new ArrayList<>(AppConfig.getCategoryList());
    }

    @Override
    public void initView() {
        mAdapter = new BaseAdapter<>(this, mListData);
        mAdapter.addItemViewDelegate(new CategoryDelegate());
        mAdapter.setOnItemClickListener(onItemClickListener);
        mRv.setLayoutManager(new LinearLayoutManager(this));
        mRv.setAdapter(mAdapter);
    }

    @OnClick(R.id.act_category_iv_back)
    protected void onBackClick(){
        finish();
    }

    private BaseAdapter.OnItemClickListener onItemClickListener = new BaseAdapter.OnItemClickListener<CategoryModel>() {
        @Override
        public void onItemClick(View view, RecyclerView.ViewHolder holder, CategoryModel data, int position) {
            
        }

        @Override
        public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, CategoryModel data, int position) {
            return false;
        }
    };

    @Override
    public void onSideSlipEvent(){
        finish();
    }
}
